<?php 
$Content = QContext::instance();
$base_url = $Content->requestUDI();
$search = $base_url;
$search['action'] = 'search';
$delete = $base_url;
$delete['action'] = 'del';
$add = $base_url;
$add['action'] = 'add';
$import = $base_url;
$import['action'] = 'import';
$smsFlag = $base_url;
$smsFlag['action'] = 'smsflag';

?>

<form id="pagerForm" method="get" action="<?php echo url($base_url,null,null,array('mode'=>'standard'));?>">
		<input type="hidden" name="pageNum" value="<?php echo $pagination['current'];?>" /> <!--【必须】value=1可以写死-->
		<input type="hidden" name="numPerPage" value="<?php echo $pagination['page_size'];?>" /> <!--【可选】每页显示多少条-->
		<input type="hidden" name="orderField" value="<?php echo $orderField;?>" />
		<input type="hidden" name="orderDirection" value="<?php echo $orderDirection;?>" />
</form>

<div class="pageHeader">
	<form rel="pagerForm" onsubmit="return navTabSearch(this);" action="<?php echo url($base_url,null,null,array('mode'=>'standard'));?>" method="get">
	<div class="searchBar">
		<ul class="searchContent">
			<li>
				<label>代理名称：</label>
				<input type="text" name="acctname" value="<?php echo isset($param['acctname'])?$param['acctname']:'';?>"/>
				<input type="hidden" name="_querymethod[acctname]" value="like">
			</li>
			<li>
				<label>状态：</label>
			<select class="combox" name="enable">
				<option value="1" <?php echo isset($param['enable'])?$param['enable']=='1'?'selected':'':'';?>>正常</option>
				<option value="0" <?php echo isset($param['enable'])?$param['enable']=='0'?'selected':'':'';?>>锁定</option>
			</select>
			</li>
		</ul>
		
		<div class="subBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
			</ul>
		</div>
	</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			
			<li><a title="确认删除此产品数据?"  target="selectedTodo" rel="ids[]" href="<?php echo url($delete)?>" class="delete"><span>批量删除</span></a></li>
			<li class="line">line</li>
			<li><a title="确认开通此代理以及下级的短信开关?" target="selectedTodo" rel="ids[]" href="<?php echo url($smsFlag)?>" class="edit"><span>批量短信开关</span></a></li>
			<li class="line">line</li>
			
			<li><a class="edit" href="<?php echo url($add)?>/id/{id}" target="dialog" height="500" warn="请选择一个产品"><span>修改</span></a></li>
			<li class="line">line</li>
			<li><a class="edit" href="<?php echo url($add)?>/" target="dialog" rel="添加代理" height="500" warn="请选择一个产品"><span>添加代理</span></a></li>
			<li class="line">line</li>
			<li><a class="edit" href="<?php echo url($base_url)?>" target="navTab" ><span>返回</span></a></li>
		</ul>
	</div>
	<table class="table" width="1200" layoutH="138">
		<thead>
			<tr>
				<th width="1%"><input type="checkbox" group="ids[]" class="checkboxCtrl"></th>
				<th width="5%" orderField="acctname" >代理商</th>
				<th width="5%" >密码</th>
				<th width="5%" >上级</th>
				<th width="3%" orderField="enable">状态</th>
				<th width="5%" align="center" orderField="balance">话费(元)</th>
				<th width="5%" orderField="overbalance">透支</th>
				<th width="5%" >模式</th>
				<th width="10%" >中继(被叫/回铃)</th>
				<th width="5%" >代理ID</th>
				<th width="10%" >费率(被叫/回铃)</th>
				<th width="3%" >套餐数</th>
				<th width="3%" >短信</th>
				
				<th width="10%" align="center">选项</th>
				
			</tr>
		</thead>
		<tbody>
			<?php foreach ($item as $k=>$v):?>
			<tr target="id" rel="<?php echo $v->id?>">
				<td><input name="ids[]" value="<?php echo $v->id?>" type="checkbox"></td>
				<td><?php echo $v->acctname?></td>
				<td><?php echo $v->password?></td>
				<td><?php echo $v->parent->acctname;?> </td>
				<td><?php echo $v->enable == 1 ?'正常':'<font color=red>冻结</font>';?></td>
				<td><?php echo $v->balance;?></td>
				<td><?php echo $v->overbalance;?></td>
				<td><?php echo $v->discharge_level == 1?'流量':'面值';?></td>
				<td><?php echo $v->a_gatewaygroup->gatewaygroupname.'/'.$v->b_gatewaygroup->gatewaygroupname;?></td>
				<td><?php echo $v->id;?></td>
				<td><?php echo $v->a_rategroup->rategroupname.'/'.$v->b_rategroup->rategroupname;?></td>
				<td><?php echo '';?></td>
				<td><?php echo $v->smsflag ? '开':'关';?></td>
				
				<td>
					<a href="<?php echo url($base_url,array('agent_id'=>$v->id,'admin_id'=>$v->admin_id),null,array('mode'=>'standard'));?>" target="navTab" >下级代理(<?php echo count($v->sub);?>)</a>
					<?php if ($v->parent->acclevel == 0):?>
					<a href="<?php echo url("card/timepay",array('id'=>$v->id))?>" target="dialog">充值</a>
					<?php else:?>
					<a href="<?php echo url("card/timemoney",array('id'=>$v->id))?>" target="dialog">充值</a>
						
					<?php endif;?>
					
				</td>
			</tr>
			<?php endforeach;?>
		</tbody>
	</table>
	<div class="panelBar">
			<div class="pages">
			<span>显示</span>
			<select name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
				<option value="20" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==20)echo 'selected=selected';?>>20</option>
				<option value="50" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==50)echo 'selected=selected';?>>50</option>
				<option value="100" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==100)echo 'selected=selected';?>>100</option>
				<option value="200" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==200)echo 'selected=selected';?>>200</option>
			</select>
				<span>共 <?php echo $pagination['record_count'];?> 条</span>
			</div>
		
		<div class="pagination" targetType="navTab" totalCount="<?php echo $pagination['record_count'];?>" numPerPage="<?php echo $pagination['page_size'];?>" pageNumShown="10" currentPage="<?php echo $pagination['current'];?>" ></div>

	</div>
</div>